package org.pombo.soe;

import org.pombo.gaf.FitnessFunction;
import org.pombo.gaf.GAFactory;
import org.pombo.gaf.GeneticAlgorithm;
import org.pombo.gtm.*;
import org.pombo.sqm.*;

public class StrategyOptimizator {

	private Game game;

	public StrategyOptimizator(Game game) {
		this.game = game;
	}

	public Strategy getOptimizedStrategy(Player player) {
		StrategyQualityMeasurer sqm = SQMFactory.getSQM(this.game, player);
		FitnessFunction<Strategy> fitnessFunction = new StrategyFitnessFunction(sqm);
		GeneticAlgorithm<Strategy> ga = GAFactory.getGeneticAlgorithm(fitnessFunction);
		for (int i = 0; i < 100; i++) {
			ga.evolve();
		}
		return ga.getFittest();
	}

}
